namespace :db do
  desc "Wypelnienie bazy danych kilkoma uzytkownikami i wydrukami. Haslo standardowe dla userow."
  task :populate => :environment do
    require 'populator'
    require 'faker'

    User.populate 5 do |user|
      user.name    = Faker::Name.name      
      user.email   = Faker::Internet.email
      user.group_id = 2
      user.crypted_password = "52bf12cb294906acb886a392ae5e6cbb911ebf275cda4452ba125e24262a7df576cc0412e0ccdd5d4d23c4a6992f2fdbd6d016e119a7143c8b17172a43748919"
      user.password_salt = '4JpD8kafsSj4-vZVUgwm'
      user.address = Faker::Address.street_address
      user.phone   = ['123 123 123', '123456789', '987654321']
      user.gg_uid = 0..12345
      user.comment = Populator.sentences(1..2)
      user.saldo  = -2..5
      user.login_count = 1..5
      user.failed_login_count = 1..5
      user.perishable_token = '2s1PW5SpoGghj63gZVAA'
      user.active = true
      user.layout = ['blue', 'green', 'orange', 'gray', 'pink', 'purple']
      user.created_at = 2.years.ago..Time.now
      Print.populate 1..4 do |print|
        print.user_id = user.id
        print.attachment_file_name = Populator.words(1..3) + '.jpg'
        print.attachment_content_type = ['application/msword', 'image/jpeg']
        print.comment = Faker::Lorem.sentence(6)
        print.pages_bw = 1..5
        print.pages_color = 1..10
        print.copies = 1..4
        print.price = 0
        print.duplex = [true, false]
        print.printed = [true, false]
        print.multipage [1, 2, 4, 8, 16]
        print.created_at = 1.years.ago..Time.now
      end
    end
  end
end